import { Component, EventEmitter, inject, Output, Input } from '@angular/core';
import { FormsModule } from '@angular/forms';
// import { NewTaskData } from '../task/task.modes';
import { TasksService } from '../tasks.service';
@Component({
  selector: 'app-new-task',
  standalone:false,
  templateUrl: './new-task.html',
  styleUrl: './new-task.scss',
})
export class NewTask {
  @Output() close = new EventEmitter<void>();
  @Input({required: true}) userId! : string;
  enteredTitle = '';
  enteredSummary = '';
  enteredDate = '';

  // enteredTitle = signal('');
  // enteredSummary = signal('');
  // enteredDate = signal('');

  private tasksService = inject(TasksService)

  onCancel() {
    this.close.emit();
  }

  onSubmit() {
    this.tasksService.addTask({
      title: this.enteredTitle,
      summary: this.enteredSummary,
      dueDate: this.enteredDate
    }, this.userId);
    this.close.emit();
  }
}
